package auth_model

import "time"

// Menu 菜单
type Menu struct {
	ID        int64     `gorm:"primaryKey;autoIncrement" json:"id"`
	ParentID  int64     `gorm:"type:bigint;default:0;index" json:"parent_id"` // 父级菜单ID
	Name      string    `gorm:"type:varchar(64);not null" json:"name"`
	Path      string    `gorm:"type:varchar(255)" json:"path"`
	Component string    `gorm:"type:varchar(255)" json:"component"`
	Icon      string    `gorm:"type:varchar(64)" json:"icon"`
	OrderNum  int       `gorm:"type:int;default:0" json:"order_num"`
	Hidden    int8      `gorm:"type:tinyint(1);default:0" json:"hidden"`     // 是否隐藏
	KeepAlive int8      `gorm:"type:tinyint(1);default:1" json:"keep_alive"` // 是否缓存
	Redirect  string    `gorm:"type:varchar(255)" json:"redirect"`
	Children  []Menu    `gorm:"-" json:"children,omitempty"` // 用来构建菜单层级、不需要映射数据库
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}

func (Menu) TableName() string { return "menus" }
